
#ifndef __SETUP_UI_H__
#define __SETUP_UI_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"
#include "file_table.h"

//-------------------------------------------类型声明-------------------------------------------//
// GIF 动画实现
typedef struct
{
	lv_task_t *task;    			// GIF 任务
	
    lv_obj_t *obj;      			// GIF 图片控件
	
	lv_img_dsc_t *img; 				// GIF 图片源组
	uint16_t index;     			// GIF 图片源组索引
	uint16_t size;      			// GIF 图片源组索引上限
	
	uint32_t addr;  				// GIF 可加载至 SDRAM 空间的起始地址	
} ui_gif_t;

//用户灯控页数据
typedef struct
{
	enum {
		LOW = 0,
		MID,
		HIGH
	} lamp_1;//低\中\高-灯亮度
	
	enum {
		IN = 0,
		OUT,
		ALL
	} lamp_2;//内\外\全灯
	
	struct {
		enum {
			_WARM_ = 0,
			_COLD_
		}color : 1;
		
		enum {
			SINGLE = 0,
			DOUBLE
		}ring : 1;
	} lamp_3;//暖\白(冷)灯 || 单环\双环
	
	enum {
		WARM = 0,
		COLD
	} lamp_4;//暖\白(冷)灯
}user_lamp_t;


//用户相册页数据
typedef struct
{
	uint16_t show_pic_x;//显示图片索引-行
	uint16_t show_pic_y;//显示图片索引-列
}user_photo_t;

//用户数据
typedef struct
{
	user_lamp_t lamp_setting;//灯光页
	//user_music_t music;//音乐页
	//user_video_t video;//视频页
	user_photo_t photo_setting;//相册页
}user_data_t;

// UI 全局节点管理 => 每一页的首节点为其父节点, animimg 表示 GIF 动画, 由图片组实现
typedef struct
{
	//开机页
	lv_obj_t *page_power;
	lv_obj_t *page_power_img_bg;
	lv_obj_t *page_power_imgbtn_power;
	
	//开机动画logo页
	lv_obj_t *page_logo;
	lv_obj_t *page_logo_animimg_logo;
	
	//全局导航页
	lv_obj_t *page_navigation;
	lv_obj_t *page_navigation_img_bg;
	lv_obj_t *page_navigation_animimg_loading;
	lv_obj_t *page_navigation_animimg_rotation_press;
	lv_obj_t *page_navigation_imgbtn_lamp;
	lv_obj_t *page_navigation_imgbtn_music;
	lv_obj_t *page_navigation_imgbtn_video;
	lv_obj_t *page_navigation_imgbtn_photo;
	lv_obj_t *page_navigation_btn_circle_center;
	
	//灯光页
	lv_obj_t *page_lamp;
	lv_obj_t *page_lamp_img_bg;
	lv_obj_t *page_lamp_img_lighting;
	lv_obj_t *page_lamp_imgbtn_back;
	lv_obj_t *page_lamp_imgbtn_1;
	lv_obj_t *page_lamp_imgbtn_2;
	lv_obj_t *page_lamp_imgbtn_3;
	lv_obj_t *page_lamp_imgbtn_4;
	
	//灯光配置子页-1
	lv_obj_t *page_lamp_1;
	lv_obj_t *page_lamp_1_img_bg;
	lv_obj_t *page_lamp_1_img_icon_1;
	lv_obj_t *page_lamp_1_img_icon_2;
	lv_obj_t *page_lamp_1_imgbtn_back;
	lv_obj_t *page_lamp_1_img_control;
	lv_obj_t *page_lamp_1_btn_control_1;
	lv_obj_t *page_lamp_1_btn_control_2;
	lv_obj_t *page_lamp_1_btn_control_3;
	
	//灯光配置子页-2
	lv_obj_t *page_lamp_2;
	lv_obj_t *page_lamp_2_img_bg;
	lv_obj_t *page_lamp_2_img_icon_1;
	lv_obj_t *page_lamp_2_img_icon_2;
	lv_obj_t *page_lamp_2_imgbtn_back;
	lv_obj_t *page_lamp_2_img_control;
	lv_obj_t *page_lamp_2_btn_control_1;
	lv_obj_t *page_lamp_2_btn_control_2;
	lv_obj_t *page_lamp_2_btn_control_3;
	
	//灯光配置子页-3
	lv_obj_t *page_lamp_3;
	lv_obj_t *page_lamp_3_img_bg;
	lv_obj_t *page_lamp_3_img_icon_1;
	lv_obj_t *page_lamp_3_img_icon_2;
	lv_obj_t *page_lamp_3_imgbtn_back;
	lv_obj_t *page_lamp_3_img_control;
	lv_obj_t *page_lamp_3_btn_control_1;
	lv_obj_t *page_lamp_3_btn_control_2;
	lv_obj_t *page_lamp_3_btn_control_3;
	lv_obj_t *page_lamp_3_btn_control_4;
	
	//灯光配置子页-4
	lv_obj_t *page_lamp_4;
	lv_obj_t *page_lamp_4_img_bg;
	lv_obj_t *page_lamp_4_img_icon_1;
	lv_obj_t *page_lamp_4_img_icon_2;
	lv_obj_t *page_lamp_4_imgbtn_back;
	lv_obj_t *page_lamp_4_img_control;
	lv_obj_t *page_lamp_4_btn_control_1;
	lv_obj_t *page_lamp_4_btn_control_2;
	
	//音乐页
	lv_obj_t *page_music;
	lv_obj_t *page_music_img_bg;
	lv_obj_t *page_music_img_icon_1;
	lv_obj_t *page_music_img_icon_2;
	lv_obj_t *page_music_imgbtn_back;
	lv_obj_t *page_music_img_song_list;
	lv_obj_t *page_music_img_song_name;
	lv_obj_t *page_music_imgbtn_control[4];//left—back \ left—rewind \ mid-pause \ right-forward
	
	//音乐播放子页
	lv_obj_t *page_music_play;
	lv_obj_t *page_music_play_img_bg;
	lv_obj_t *page_music_play_img_icon;
	lv_obj_t *page_music_play_imgbtn_back;
	lv_obj_t *page_music_play_img_song_name;
	lv_obj_t *page_music_play_imgbtn_control[4];//left—back \ left—rewind \ mid-pause \ right-forward
	
	//视频页
	lv_obj_t *page_video;
	lv_obj_t *page_video_img_bg;
	lv_obj_t *page_video_img_icon;
	lv_obj_t *page_video_imgbtn_back;
	
	lv_obj_t *page_video_tabview_list[2];//2行,每行显示2个可点击的 imgbtn,可拖动/滑动, 共8个
	lv_obj_t *page_video_imgbtn_list[2][4]; 
	lv_obj_t *page_video_label_list[2][4];
	
	lv_obj_t *page_video_imgbtn_left;
	lv_obj_t *page_video_imgbtn_right;
	
	//视频播放子页
	lv_obj_t *page_video_play;
	lv_obj_t *page_video_play_img_bg;
	lv_obj_t *page_video_play_imgbtn_back;
	
	//相册页
	lv_obj_t *page_photo;
	lv_obj_t *page_photo_img_bg;
	lv_obj_t *page_photo_img_icon_1;
	lv_obj_t *page_photo_img_icon_2;
	lv_obj_t *page_photo_imgbtn_back;
	lv_obj_t *page_photo_img_icon_list[3][2];//3行,每行2个不可点击的 img, 共6个
	lv_obj_t *page_photo_imgbtn_list[3][4];  //3行,每行4个可点击的 imgbtn, 共12个
	
	//相册显示子页-(因页面内容及布局完全一致,为减少代码量 - list_1/2/3复用)
	lv_obj_t *page_photo_show;
	lv_obj_t *page_photo_show_img_bg;
	lv_obj_t *page_photo_show_img_show;
	lv_obj_t *page_photo_show_img_icon_1;
	lv_obj_t *page_photo_show_img_icon_2;
	lv_obj_t *page_photo_show_imgbtn_back;
	lv_obj_t *page_photo_show_imgbtn_left;
	lv_obj_t *page_photo_show_imgbtn_right;
}lv_ui;

//-------------------------------------------全局变量-------------------------------------------//
extern lv_ui GUI;

extern user_data_t User_Data;

extern ui_gif_t GIF_Navigation;

//-------------------------------------------函数声明-------------------------------------------//
void gif_task_navigation_rotation(lv_task_t *task);
void gif_task_navigation_press(lv_task_t *task);

void setup_ui(lv_ui *ui);

void setup_page_power(lv_ui *ui);

void setup_page_logo(lv_ui *ui);

void setup_page_navigation_loading(lv_ui *ui);
void setup_page_navigation(lv_ui *ui);

void setup_page_lamp(lv_ui *ui);
void setup_page_lamp_1(lv_ui *ui);
void setup_page_lamp_2(lv_ui *ui);
void setup_page_lamp_3(lv_ui *ui);
void setup_page_lamp_4(lv_ui *ui);

void setup_page_music(lv_ui *ui);
void setup_page_music_play(lv_ui *ui);

void setup_page_video(lv_ui *ui);
void setup_page_video_play(lv_ui *ui);

void setup_page_photo(lv_ui *ui);
void setup_page_photo_show(lv_ui *ui);

#ifdef __cplusplus
}
#endif

#endif //__SETUP_UI_H__